﻿<Window x:Class="MiniTwitter.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:MiniTwitter="clr-namespace:MiniTwitter"
    xmlns:MiniTwitter_Input="clr-namespace:MiniTwitter.Input"
		xmlns:MiniTwitter_Properties="clr-namespace:MiniTwitter.Properties"
    x:Name="Window"
    Title="MiniTwitter" Width="350" Height="450" MinWidth="150" MinHeight="100" ResizeMode="CanResizeWithGrip"
    Style="{DynamicResource MainWindowStyle}"
		FontFamily="{Binding Source={x:Static MiniTwitter_Properties:Settings.Default}, Path=FontName}" 
		ShowInTaskbar="{Binding Source={x:Static MiniTwitter_Properties:Settings.Default}, Path=ShowInTaskbar}"
		Icon="Resources\MiniTwitter_small.ico"
    Loaded="MainWindow_Loaded" Initialized="MainWindow_Initialized" Activated="MainWindow_Activated" Closing="MainWindow_Closing">
	<!--edited by yuki, FontFamily, ShowInTaskbar-->
	<Window.CommandBindings>
		<CommandBinding Command="MiniTwitter_Input:Commands.Update" Executed="UpdateCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.Refresh" Executed="RefreshCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.Reply" Executed="ReplyCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.ReTweet" Executed="ReTweetCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.ReplyMessage" Executed="ReplyMessageCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.Delete" Executed="DeleteCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.Favorite" Executed="FavoriteCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.TimelineStyle" Executed="TimelineStyleCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.MoveToUserPage" Executed="MoveToUserPageCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.MoveToStatusPage" Executed="MoveToStatusPageCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.MoveToReplyPage" Executed="MoveToReplyPageCommand_Executed" />
		<CommandBinding Command="MiniTwitter_Input:Commands.ReadAll" Executed="ReadAllCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.Copy" Executed="CopyCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.CopyUrl" Executed="CopyUrlCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.SortCategory" Executed="SortCategoryCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.SortDirection" Executed="SortDirectionCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.AddTimeline" Executed="AddTimelineCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.EditTimeline" Executed="EditTimelineCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.DeleteTimeline" Executed="DeleteTimelineCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.ClearTimeline" Executed="ClearTimelineCommand_Executed"/>
		<!--Command below this line added by yuki.-->
		<CommandBinding Command="MiniTwitter_Input:Commands.TmpOffPopup" Executed="TmpOffPopupCommand_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.DisplayTwitForm" Executed="DisplayTwitForm_Executed"/>
		<CommandBinding Command="MiniTwitter_Input:Commands.SwitchDisplayTwitForm" Executed="SwitchTwitForm_Executed"/>
	</Window.CommandBindings>
	<Window.Resources>
		<ContextMenu x:Key="notifyMenu">
			<MenuItem Header="終了(_X)" Click="CloseMenuItem_Click" />
		</ContextMenu>
	</Window.Resources>
	<!--edited by yuki.
		-changed the order, "statusbar", "input area", "timeline"
	-->
	<DockPanel>
		<StatusBar DockPanel.Dock="Bottom" Padding="0,0,15,0" VerticalContentAlignment="Center">
			<StatusBarItem>
				<TextBlock Text="{Binding ElementName=Window, Path=StatusText}"/>
			</StatusBarItem>
			<StatusBarItem HorizontalAlignment="Right">
				<StackPanel Orientation="Horizontal">
					<!--edited by yuki.-->
				
					<Button Margin="0,0,3,0" Padding="0" Command="MiniTwitter_Input:Commands.SwitchDisplayTwitForm" CommandParameter="{Binding}"
							Style="{DynamicResource ImageButtonStyle}">
						<Image Width="14" Height="14" Margin="0,0,5,0" Style="{DynamicResource TwitFormImageStyle}"/>
					</Button>
					
					<Button Margin="0,0,3,0" Padding="0" Command="MiniTwitter_Input:Commands.TmpOffPopup" CommandParameter="{Binding}" 
							Style="{DynamicResource ImageButtonStyle}">
						<Image Width="14" Height="14" Margin="0,0,5,0" Style="{DynamicResource PopupImageStyle}"/>
					</Button>
					<!--edited by yuki. end.-->
					<TextBlock Text="{Binding ElementName=TimelineTabControl, Path=SelectedContent.Items.Count, StringFormat=\{0\} 件}"/>
				</StackPanel>
			</StatusBarItem>
		</StatusBar>

		<Grid DockPanel.Dock="Bottom" Margin="6">
			<!--added by yuki.-->

			<!--Hide when window is not active-->
			<!--
			<Grid.Style>
				<Style TargetType="Grid">
					<Style.Triggers>
						<MultiDataTrigger>
							<MultiDataTrigger.Conditions>
								<Condition Binding="{Binding ElementName=Window, Path=IsMouseOver}" Value="False"/>
								<Condition Binding="{Binding ElementName=TweetTextBox, Path=Text.Length}" Value="0"/>
							</MultiDataTrigger.Conditions>
							<Setter Property="Visibility" Value="Collapsed"/>
						</MultiDataTrigger>
					</Style.Triggers>
				</Style>
			</Grid.Style>
			-->
			<Grid.Style>
				<Style TargetType="Grid">
					<Style.Triggers>
						<DataTrigger Binding="{Binding ElementName=Window, Path=IsShowTwitForm}" Value="False">
							<Setter Property="Visibility" Value="Collapsed"/>
						</DataTrigger>
					</Style.Triggers>
				</Style>
			</Grid.Style>
			<!--end of addition by yuki-->
		
			<Grid.RowDefinitions>
				<RowDefinition/>
				<RowDefinition/>
				<RowDefinition/>
				<RowDefinition/>
			</Grid.RowDefinitions>
			<TextBlock Grid.Row="0" Text="What are you doing?" VerticalAlignment="Center" Style="{DynamicResource HeaderTextBlockStyle}"/>
			<TextBlock Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center"
                       Text="{Binding ElementName=TweetTextBox, Path=Text.Length, Converter={StaticResource TextCountConverter}}"
                       Style="{DynamicResource CounterTextBlockStyle}"/>
			<TextBox x:Name="TweetTextBox" Grid.Row="1" Margin="0,4.5,0,6" TextWrapping="Wrap" TextChanged="TweetTextBox_TextChanged"
                     VerticalScrollBarVisibility="Auto" KeyDown="TweetTextBox_KeyDown" Style="{DynamicResource TweetTextBoxStyle}">
				<TextBox.CommandBindings>
					<CommandBinding Command="Paste" Executed="PasteCommand_Executed" />
				</TextBox.CommandBindings>
			</TextBox>
			<Popup x:Name="popup" StaysOpen="False" Focusable="False" MaxHeight="200">
				<ListBox x:Name="usersListBox" Focusable="False" Background="White" Foreground="Black" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
					<ListBox.ItemTemplate>
						<DataTemplate>
							<StackPanel Orientation="Horizontal">
								<TextBlock Text="@" />
								<TextBlock Text="{Binding Path=ScreenName}" />
							</StackPanel>
						</DataTemplate>
					</ListBox.ItemTemplate>
				</ListBox>
			</Popup>
			<Button Grid.Row="2" Content="update" Command="MiniTwitter_Input:Commands.Update"
                    CommandParameter="{Binding ElementName=TweetTextBox, Path=Text}" Style="{DynamicResource UpdateButtonStyle}"/>
			<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
				<Button Margin="0,0,3,0" Click="HomeButton_Click" Style="{DynamicResource ImageButtonStyle}">
					<Image Style="{DynamicResource HomeImageStyle}"/>
				</Button>
				<ToggleButton x:Name="searchButton" Margin="0,0,3,0" Style="{DynamicResource ImageToggleButtonStyle}">
					<Image Style="{DynamicResource SearchImageStyle}"/>
				</ToggleButton>
				<Button Margin="0,0,3,0" Command="MiniTwitter_Input:Commands.Refresh"
                        Style="{DynamicResource ImageButtonStyle}">
					<Image Style="{DynamicResource ArrowRefreshImageStyle}"/>
				</Button>
				<Button Click="SettingButton_Click" Style="{DynamicResource ImageButtonStyle}">
					<Image Style="{DynamicResource SettingImageStyle}"/>
				</Button>
			</StackPanel>
			<Grid Grid.Row="3" Margin="0,6,0,0" Visibility="{Binding Path=IsChecked, ElementName=searchButton, Converter={StaticResource BooleanToVisibilityConverter}}">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition Width="*"/>
					<ColumnDefinition Width="Auto"/>
				</Grid.ColumnDefinitions>
				<TextBlock Text="検索:" Grid.Column="0" FontWeight="Bold" Margin="0,0,3,0" VerticalAlignment="Center" />
				<TextBox x:Name="searchTermTextBox" Grid.Column="1" HorizontalAlignment="Stretch" KeyUp="SearchTermTextBox_KeyUp" />
				<Button Grid.Column="2" Style="{DynamicResource ImageButtonStyle}" Click="SearchCancelButton_Click">
					<Image Style="{DynamicResource CrossImageStyle}" />
				</Button>
			</Grid>
		</Grid>
		<ListBox x:Name="test"/>
		<TabControl x:Name="TimelineTabControl" DockPanel.Dock="Top" DisplayMemberPath="Name" SelectedIndex="0"
                    ItemsSource="{Binding ElementName=Window, Path=Timelines}" Style="{DynamicResource TimelineTabControlStyle}"
                    ItemContainerStyle="{DynamicResource TimelineTabItemStyle}" IsSynchronizedWithCurrentItem="True">
			<TabControl.ContentTemplate>
				<DataTemplate>
					<ListBox x:Name="TimelineListBox" IsSynchronizedWithCurrentItem="True" AlternationCount="2"
                             VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling"
                             ScrollViewer.IsDeferredScrollingEnabled="True" SelectionChanged="TimelineListBox_SelectionChanged"
                             MouseDoubleClick="TimelineListBox_MouseDoubleClick" ItemsSource="{Binding Path=Items}"
                             Style="{DynamicResource TimelineListBoxStyle}" ItemContainerStyle="{DynamicResource TimelineListBoxItemStyle}"
                             ItemTemplateSelector="{StaticResource TimelineStyleSelector}" HorizontalContentAlignment="Stretch">
						<ListBox.CommandBindings>
							<CommandBinding Command="MiniTwitter_Input:Commands.LineUp" Executed="LineUp_Executed"/>
							<CommandBinding Command="MiniTwitter_Input:Commands.LineDown" Executed="LineDown_Executed"/>
						</ListBox.CommandBindings>
						<ListBox.InputBindings>
							<KeyBinding Command="MiniTwitter_Input:Commands.LineUp" Gesture="CTRL+ALT+J"/>
							<KeyBinding Command="MiniTwitter_Input:Commands.LineDown" Gesture="CTRL+ALT+K"/>
						</ListBox.InputBindings>
					</ListBox>
				</DataTemplate>
			</TabControl.ContentTemplate>
		</TabControl>
	</DockPanel>
</Window>
